home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** The long lost high-level and FSSpec File Manager functions.
- **
- ** by Jim Luther, Apple Developer Technical Support
- **
- ** File: MoreFiles.h
- **
- ** Copyright © 1992-1994 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes.
- */
-
- #ifndef __MOREFILES__
- #define __MOREFILES__
-
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __FILES__
- #include <Files.h>
- #endif
-
- /* Sharing.h should be in Files.h, but isn't yet... */
- //#ifndef __SHARING__
- //#include "Sharing.h"
- //#endif
-
-
- /*****************************************************************************/
-
- pascal OSErr HGetVolParms(StringPtr volName,
- short vRefNum,
- GetVolParmsInfoBuffer *volParmsInfo,
- long *infoSize);
- /* Use HGetVolParms to determine the characteristics of a volume.
- A result of paramErr usually just means the volume doesn't
- support PBHGetVolParms and the feature you were going to check
- for isn't available.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- volParmsInfo input: Pointer to GetVolParmsInfoBuffer where the
- volume attributes information is returned.
- output: Atributes information.
- infoSize input: Size of buffer pointed to by volParmsInfo.
- output: Size of data actually returned.
- */
-
- /*****************************************************************************/
-
- pascal OSErr HCreateMinimum(short vRefNum,
- long dirID,
- const Str255 fileName);
- /* Use HCreateMinimum to create a new file without attempting to set the
- creator and file type of the new file. This function is needed to
- create a file in an AppleShare "drop box" where the user can make
- changes, but cannot see folder or files.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- fileName input: The name of the new file.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpCreateMinimum(const FSSpec *spec);
- /* Use FSpCreateMinimum to create a new file without attempting to set
- the creator and file type of the new file. This function is needed to
- create a file in an AppleShare "dropbox" where the user can make
- changes, but cannot see folder or files.
-
- spec input: An FSSpec record specifying the file to create.
- */
-
- /*****************************************************************************/
-
- pascal OSErr ExchangeFiles(short vRefNum,
- long srcDirID,
- const Str255 srcName,
- long dstDirID,
- const Str255 dstName);
- /* Use ExchangeFiles to exchange the data stored in two files on the
- same volume.
-
- vRefNum input: Volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source file name.
- dstDirID input: Destination directory ID.
- dstName input: Destination file name.
- */
-
- /*****************************************************************************/
-
- pascal OSErr ResolveFileIDRef(StringPtr volName,
- short vRefNum,
- long fileID,
- long *parID,
- StringPtr fileName);
- /* Use ResolveFileIDRef to retrieve the filename and parent directory ID
- of the file with the specified file ID.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- fileID input: The file ID.
- vRefNum input: Volume specification.
- parID output: The parent directory ID of the file.
- name input: Points to a buffer (minimum Str63) where the filename
- is to be returned or must be nil.
- output: The filename.
- */
-
- /*****************************************************************************/
-
- pascal OSErr CreateFileIDRef(short vRefNum,
- long parID,
- const Str255 fileName,
- long *fileID);
- /* Use CreateFileIDRef to establish a file ID for a file.
-
- vRefNum input: Volume specification.
- parID input: Directory ID.
- fileName input: The name of the file.
- fileID output: The file ID.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpCreateFileIDRef(const FSSpec *spec,
- long *fileID);
- /* Use FSpCreateFileIDRef to establish a file ID for a file.
-
- spec input: An FSSpec record specifying the file.
- fileID output: The file ID.
- */
-
- /*****************************************************************************/
-
- pascal OSErr DeleteFileIDRef(StringPtr volName,
- short vRefNum,
- long fileID);
- /* Use DeleteFileIDRef to delete a file ID reference.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- fileID input: The file ID.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FlushFile(short refNum);
- /* Use FlushFile to write the contents of a file's access path buffer.
-
- refNum input: The file reference number of an open file.
- */
-
- /*****************************************************************************/
-
- pascal OSErr LockRange(short refNum,
- long rangeLength,
- long rangeStart);
- /* Use LockRange to lock a portion of a file.
-
- refNum input: The file reference number of an open file.
- rangeLength input: The number of bytes in the range.
- rangeStart input: The starting byte in the range to lock.
- */
-
- /*****************************************************************************/
-
- pascal OSErr UnlockRange(short refNum,
- long rangeLength,
- long rangeStart);
- /* Use UnlockRange to unlock a previously locked range.
-
- refNum input: The file reference number of an open file.
- rangeLength input: The number of bytes in the range.
- rangeStart input: The starting byte in the range to unlock.
- */
-
- /*****************************************************************************/
-
- pascal OSErr GetForeignPrivs(short vRefNum,
- long dirID,
- StringPtr name,
- Ptr foreignPrivBuffer,
- long *foreignPrivSize,
- long *foreignPrivInfo1,
- long *foreignPrivInfo2,
- long *foreignPrivInfo3,
- long *foreignPrivInfo4);
- /* Use GetForeignPrivs to determine the native access-control
- information for a file or directory stored on a volume managed by
- a foreign file system.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- foreignPrivBuffer input: Pointer to buffer where the privilege
- information is returned.
- output: Privilege information.
- foreignPrivSize input: Size of buffer pointed to by
- foreignPrivBuffer.
- output: Amount of buffer actually used.
- foreignPrivInfo1 output: Information specific to privilege model.
- foreignPrivInfo2 output: Information specific to privilege model.
- foreignPrivInfo3 output: Information specific to privilege model.
- foreignPrivInfo4 output: Information specific to privilege model.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpGetForeignPrivs(const FSSpec *spec,
- Ptr foreignPrivBuffer,
- long *foreignPrivSize,
- long *foreignPrivInfo1,
- long *foreignPrivInfo2,
- long *foreignPrivInfo3,
- long *foreignPrivInfo4);
- /* Use FSpGetForeignPrivs to determine the native access-control
- information for a file or directory stored on a volume managed by
- a foreign file system.
-
- spec input: An FSSpec record specifying the object.
- foreignPrivBuffer input: Pointer to buffer where the privilege
- information is returned.
- output: Privilege information.
- foreignPrivSize input: Size of buffer pointed to by
- foreignPrivBuffer.
- output: Amount of buffer actually used.
- foreignPrivInfo1 output: Information specific to privilege model.
- foreignPrivInfo2 output: Information specific to privilege model.
- foreignPrivInfo3 output: Information specific to privilege model.
- foreignPrivInfo4 output: Information specific to privilege model.
- */
-
- /*****************************************************************************/
-
- pascal OSErr SetForeignPrivs(short vRefNum,
- long dirID,
- StringPtr name,
- Ptr foreignPrivBuffer,
- long *foreignPrivSize,
- long foreignPrivInfo1,
- long foreignPrivInfo2,
- long foreignPrivInfo3,
- long foreignPrivInfo4);
- /* Use SetForeignPrivs to change the native access-control information
- for a file or directory stored on a volume managed by a foreign
- file system.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- foreignPrivBuffer input: Pointer to privilege information buffer.
- foreignPrivSize input: Size of buffer pointed to by
- foreignPrivBuffer.
- output: Amount of buffer actually used.
- foreignPrivInfo1 input: Information specific to privilege model.
- foreignPrivInfo2 input: Information specific to privilege model.
- foreignPrivInfo3 input: Information specific to privilege model.
- foreignPrivInfo4 input: Information specific to privilege model.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpSetForeignPrivs(const FSSpec *spec,
- Ptr foreignPrivBuffer,
- long *foreignPrivSize,
- long foreignPrivInfo1,
- long foreignPrivInfo2,
- long foreignPrivInfo3,
- long foreignPrivInfo4);
- /* Use FSpSetForeignPrivs to change the native access-control information
- for a file or directory stored on a volume managed by a foreign
- file system.
-
- spec input: An FSSpec record specifying the object.
- foreignPrivBuffer input: Pointer to privilege information buffer.
- foreignPrivSize input: Size of buffer pointed to by
- foreignPrivBuffer.
- output: Amount of buffer actually used.
- foreignPrivInfo1 input: Information specific to privilege model.
- foreignPrivInfo2 input: Information specific to privilege model.
- foreignPrivInfo3 input: Information specific to privilege model.
- foreignPrivInfo4 input: Information specific to privilege model.
- */
-
- /*****************************************************************************/
-
- pascal OSErr HGetLogInInfo(StringPtr volName,
- short vRefNum,
- short *loginMethod,
- StringPtr userName);
- /* Use HGetLogInInfo to determine the login method and user name used to
- log on to a particular shared volume.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: The volume reference number.
- loginMethod output: The login method used (kNoUserAuthentication,
- kPassword, kEncryptPassword, or
- kTwoWayEncryptPassword).
- userName input: Points to a buffer (minimum Str31) where the user
- name is to be returned or must be nil.
- output: The user name.
- */
-
- /*****************************************************************************/
-
- pascal OSErr HGetDirAccess(short vRefNum,
- long dirID,
- StringPtr name,
- long *ownerID,
- long *groupID,
- long *accessRights);
- /* Use HGetDirAccess to get the directory access control information for
- a directory on a shared volume.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil if dirID
- specifies the directory.
- ownerID output: The directory's owner ID.
- groupID output: The directory's group ID or
- 0 if no group affiliation.
- accessRights output: The directory's access rights.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpGetDirAccess(const FSSpec *spec,
- long *ownerID,
- long *groupID,
- long *accessRights);
- /* Use FSpGetDirAccess to get the directory access control information
- for a directory on a shared volume.
-
- spec input: An FSSpec record specifying the directory.
- ownerID output: The directory's owner ID.
- groupID output: The directory's group ID or
- 0 if no group affiliation.
- accessRights output: The directory's access rights.
- */
-
- /*****************************************************************************/
-
- pascal OSErr HSetDirAccess(short vRefNum,
- long dirID,
- StringPtr name,
- long ownerID,
- long groupID,
- long accessRights);
- /* Use HSetDirAccess to change the directory access control information
- for a directory on a shared volume.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil if dirID
- specifies the directory.
- ownerID output: The directory's owner ID.
- groupID output: The directory's group ID or
- 0 if no group affiliation.
- accessRights output: The directory's access rights.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpSetDirAccess(const FSSpec *spec,
- long ownerID,
- long groupID,
- long accessRights);
- /* Use FSpSetDirAccess to change the directory access control information
- for a directory on a shared volume.
-
- spec input: An FSSpec record specifying the directory.
- ownerID output: The directory's owner ID.
- groupID output: The directory's group ID or
- 0 if no group affiliation.
- accessRights output: The directory's access rights.
- */
-
- /*****************************************************************************/
-
- pascal OSErr HMapID(StringPtr volName,
- short vRefNum,
- long ID,
- short objType,
- StringPtr name);
- /* Use HMapID to determine the name of a user or group if you know the
- user or group ID.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- objType input: The mapping function code: 1 if you're mapping a
- user ID to a user name or 2 if you're mapping a
- group ID to a group name.
- name input: Points to a buffer (minimum Str31) where the user
- or group name is to be returned or must be nil.
- output: The user or group name.
- */
-
- /*****************************************************************************/
-
- pascal OSErr HMapName(StringPtr volName,
- short vRefNum,
- const Str255 name,
- short objType,
- long *ID);
- /* Use HMapName to determine the user or group ID if you know the user or
- group name.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- name input: The user or group name.
- objType input: The mapping function code: 3 if you're mapping a
- user name to a user ID or 4 if you're mapping a
- group name to a group ID.
- ID output: The user or group ID.
- */
-
- /*****************************************************************************/
-
- pascal OSErr HCopyFile(short srcVRefNum,
- long srcDirID,
- const Str255 srcName,
- short dstVRefNum,
- long dstDirID,
- StringPtr dstPathname,
- StringPtr copyName);
- /* Use HCopyFile to duplicate a file and optionally to rename it.
- The source and destination volumes must be on the same file server.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source file name.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstPathname input: Pointer to destination directory name, or
- nil when dstDirID specifies a directory.
- copyName input: Points to the new file name if the file is to be
- renamed or nil if the file isn't to be renamed.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpCopyFile(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- StringPtr copyName);
- /* Use FSpCopyFile to duplicate a file and optionally to rename it.
- The source and destination volumes must be on the same file server.
-
- srcSpec input: An FSSpec record specifying the source file.
- dstSpec input: An FSSpec record specifying the destination
- directory.
- copyName input: Points to the new file name if the file is to be
- renamed or nil if the file isn't to be renamed.
- */
-
- /*****************************************************************************/
-
- pascal OSErr HMoveRename(short vRefNum,
- long srcDirID,
- const Str255 srcName,
- long dstDirID,
- StringPtr dstpathName,
- StringPtr copyName);
- /* Use HMoveRename to move a file or directory and optionally to rename
- it. The source and destination locations must be on the same shared
- volume.
-
- vRefNum input: Volume specification.
- srcDirID input: Source directory ID.
- srcName input: The source object name.
- dstDirID input: Destination directory ID.
- dstName input: Pointer to destination directory name, or
- nil when dstDirID specifies a directory.
- copyName input: Points to the new name if the object is to be
- renamed or nil if the object isn't to be renamed.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpMoveRename(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- StringPtr copyName);
- /* Use FSpMoveRename to move a file or directory and optionally to
- rename it. The source and destination locations must be on the same
- shared volume.
-
- srcSpec input: An FSSpec record specifying the source object.
- dstSpec input: An FSSpec record specifying the destination
- directory.
- copyName input: Points to the new name if the object is to be
- renamed or nil if the object isn't to be renamed.
- */
-
- /*****************************************************************************/
-
- pascal OSErr GetVolMountInfoSize(StringPtr volName,
- short vRefNum,
- short *size);
- /* Use GetVolMountInfoSize to determine the how much space to allocate
- for a volume mounting information record.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- size output: The space needed (in bytes) of the volume mounting
- information record.
- */
-
- /*****************************************************************************/
-
- pascal OSErr GetVolMountInfo(StringPtr volName,
- short vRefNum,
- Ptr volMountInfo);
- /* Use GetVolMountInfo to retrieve a volume mounting information record
- containing all the information needed to mount the volume, except
- for passwords.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- volMountInfo output: Points to a volume mounting information
- record where the mounting information is to
- be returned.
- */
-
- /*****************************************************************************/
-
- pascal OSErr VolumeMount(Ptr volMountInfo,
- short *vRefNum);
- /* Use VolumeMount to mount a volume using a volume mounting information
- record.
-
- volMountInfo input: Points to a volume mounting information record.
- vRefNum output: A volume reference number.
- */
-
- /*****************************************************************************/
-
- pascal OSErr Share(short vRefNum,
- long dirID,
- StringPtr name);
- /* Use Share to establish a local volume or directory as a share point.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil if dirID
- specifies the directory.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpShare(const FSSpec *spec);
- /* Use FSpShare to establish a local volume or directory as a share point.
-
- spec input: An FSSpec record specifying the share point.
- */
-
- /*****************************************************************************/
-
- pascal OSErr Unshare(short vRefNum,
- long dirID,
- StringPtr name);
- /* Use Unshare to remove a share point.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil if dirID
- specifies the directory.
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpUnshare(const FSSpec *spec);
- /* Use FSpUnshare to remove a share point.
-
- spec input: An FSSpec record specifying the share point.
- */
-
- /*****************************************************************************/
-
- pascal OSErr GetUGEntry(short objType,
- StringPtr objName,
- long *objID);
- /* Use GetUGEntry to get a list of user or group entries from the
- local file server.
-
- objType input: The object type: -1 = group; 0 = user
- objName input: Points to a buffer (minimum Str31) where the user
- or group name is to be returned or must be nil.
- output: The user or group name.
- objID input: O to get the first user or group. If the entry objID
- last returned by GetUGEntry is passed, then user or
- group whose alphabetically next in the list of entries
- is returned.
- output: The user or group ID.
- */
-
- /*****************************************************************************/
-
- #endif
-